package com.cnostar.demo.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * TODO
 * @Date 2020/3/24 18:32
 * @Author ZhuFeng
 * @Version 2.0
 */
@Component
@Slf4j
public class Task {


    @Scheduled(cron = "*/30 * * * * ?")
    public void syn_seconds(){
        String name = Thread.currentThread().getName();
        log.info("===》每10秒执行一次,thread【{}】",name);
        try {
            Thread.sleep(15 * 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    @Scheduled(cron = "*/5 * * * * ?")
    public void syn_mmmm(){
        String name = Thread.currentThread().getName();
        log.info("===》每5秒执行一次,thread【{}】",name);
        try {
            Thread.sleep(10* 1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
